-
Notifications
You must be signed in to change notification settings - Fork 34
Provide digitalPinToPort and related functions #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It appears that some boards use memory-mapped I/O to read/write pins. To support that we have an array that can hold pin values. A more elaborate approach would be to connect to the pin logs, but this seems like a decent first step (and allows some files to compile that didn't compile before).
I'm inclined to merge this, as the unit tests look sensible. The I'll merge this by Monday unless @per1234 or @matthijskooijman see any dealbreakers in there. |
I'm not sure if this is the best approach, but it's nothing that can't be improved on later, I think. For completeness, I think there's also a similar macro to get at the port's direction register, that could maybe be added (or later, of course). It's a bit memory-inefficient (allocating 1 byte per pin to store one bit), but that's not really an issue when running CI either. One thing that I'm unsure about is the 256 extra pins being allocated as "padding". I'd say that pin numbers run from 0 to |
I've removed the padding and limited the code to AVR only. Any other suggestions? |
Responding to comments in #193, which are indeed better placed here.
Yes, that's what I'd do for now. Things can be added for other architectures, but that requires careful review of what the relevent Arduino cores implement. Also, I'd expect that AVR is the most likely one to have sketches that use this semi-internal API, so this would cover most cases. As for the padding and other boards, I'd think that supporting those particular code and Ethernet library, would be a separate thing (if it's really desirable at all). From another quick glance, this looks ok to merge to me. |
8160f2a
to
e9d37db
Compare
Thanks for the discussion on this! |
I don't understand this very well, but it appears that some boards use memory-mapped I/O to read/write pins. To support that style of code this PR adds an array that can hold pin values. A more elaborate approach would be to connect to the pin logs, but this seems like a decent first step (and allows some files to compile that didn't compile before). Fixes #193.